// /**
//  * 写一个 mySetInterVal(fn, a, b),每次间隔 a,a+b,a+2b 的时间，然后写一个 myClear，停止上面的 mySetInterVal
//  */

// const mySetInterVal = (fn, a, b) => {
//     this.a = a
//     this.b = b
//     this.time = 0
//     this.handler = undefined
//     this.start = () => {
//         this.handler = setTimeout(() => {
//             fn()
//             this.start()
//             this.time++
//             console.log(this.a + this.time * this.b)
//         }, this.a + this.time * this.b)
//     }

//     this.stop = () => {
//         clearTimeout(this.handler)
//         this.time = 0
//     }
// }


// const a =  mySetInterVal(() => console.log('123'), 1000, 2000)
// a.start()
// a.stop()


function mySetInterVal(fn, a, b) {
    this.a = a;
    this.b = b;
    this.time = 0;
    this.handle = -1;
    this.start = () => {
        this.handle = setTimeout(() => {
            fn();
            this.time++;
            console.log( this.a + this.time * this.b);
            this.start();
        }, this.a + this.time * this.b);
    }

    this.stop = () => {
        clearTimeout(this.handle);
        this.time = 0;
    }
}

var a = new mySetInterVal(() => {console.log('123')},1000, 2000 );
a.start();
a.stop()